package com.it.gmall.realtime.util

import io.searchbox.client.config.HttpClientConfig
import io.searchbox.client.{JestClient, JestClientFactory}

/**
 * desc:程序中操作ES的工具类。
 *
 * @author : code1997
 * @date :2021-01-2021/1/26 23:03
 */
object MyESUtil {
  private var factory: JestClientFactory=null;

  def getClient:JestClient={
    if(factory==null){
      build();
    }
    factory.getObject;
  }
  def build():Unit={
    factory = new JestClientFactory;
    factory.setHttpClientConfig(
      new HttpClientConfig.Builder("http://hadoop02:9200")
        .multiThreaded(true)
        .maxTotalConnection(20)
        .connTimeout(10000)
        .readTimeout(1000).build())
  }

}
